{literal}
<script type="text/javascript">
<!--
function confirmDelete(articleId) {
if (confirm("This will delete the category (But no files). Continue?"))
document.location = "admin.php?page=downloads&action=delete&id=" + articleId;
}

function deletedown(photoid, albumid) {
if (confirm("This will remove the download from the category (File will not be deleted). Continue?"))
document.location = "admin.php?page=downloads&action=deletedown&did=" + photoid + "&id=" + albumid;
}

function confirmPublish(articleId, al)
{
    if (confirm("This will publish the download. Continue?")){/literal}
    document.location = "{$pagename}&action=publish&did=" + articleId + "&id=" + al;{literal}
}

function confirmunPublish(articleId, al)
{
    if (confirm("This will unpublish the download. Continue?")){/literal}
    document.location = "{$pagename}&action=unpublish&did=" + articleId + "&id=" + al;{literal}
}

function allowallup()
{
  if (document.getElementById('allowup').value == "Allow All")
  {
   {/literal} 
    {section name=groups loop=$numgroups}
        document.getElementById('u{$group[groups].id}').checked=true;
    {/section}
    {literal}
    document.getElementById('allowup').value = "Disallow All";
  }
  else if (document.getElementById('allowup').value == "Disallow All")
  {
   {/literal} 
    {section name=groups loop=$numgroups}
        document.getElementById('u{$group[groups].id}').checked=false;
    {/section}
    {literal}
    document.getElementById('allowup').value = "Allow All";
  }
}

function allowalldown()
{
  if (document.getElementById('allowdown').value == "Allow All")
  {
   {/literal} 
    {section name=groups loop=$numgroups}
        document.getElementById('d{$group[groups].id}').checked=true;
    {/section}
    {literal}
    document.getElementById('dguest').checked=true;
    document.getElementById('allowdown').value = "Disallow All";
  }
  else if (document.getElementById('allowdown').value == "Disallow All")
  {
   {/literal} 
    {section name=groups loop=$numgroups}
        document.getElementById('d{$group[groups].id}').checked=false;
    {/section}
    {literal}
    document.getElementById('dguest').checked=false;
    document.getElementById('allowdown').value = "Allow All";
  }
}
//-->
</script>
{/literal}
{if $action != 'view' && $action != "adddown" && $action != "editdown" && $action != "edit" && $action != "add"}
{if $num_cats > 0}
<h2>Download Categories</h2>
<div align="left"><input type="button" class="button" value="Add Download Category" onclick="window.location='{$pagename}&amp;action=add'" /></div>
<table width="100%" border="0" cellspacing="1" cellpadding="4" align="center" class="table">
	  <tr>
		<th width="10%" class="smallhead">Action</th>
		<th width="15%" class="smallhead">Category</th>
	  </tr> 
	 {section name=catloop loop=$num_cats}
		 <tr>
			<td class="text"><a href="{$pagename}&amp;action=view&amp;id={$cats[catloop].id}"><img src="{$tempdir}admin/images/mod.gif" border="0" alt="View {$cats[catloop].name} items" title="View {$cats[catloop].name} items" /></a> - <a href="{$pagename}&amp;action=edit&amp;id={$cats[catloop].id}"><img src="{$tempdir}admin/images/edit.gif" border="0" alt="Edit {$cats[catloop].name}" title="Edit {$cats[catloop].name}" /></a> - <a href="javascript:confirmDelete({$cats[catloop].id})"><img src="{$tempdir}admin/images/delete.gif" border="0" alt="Delete {$cats[catloop].name}" title="Delete {$cats[catloop].name}" /></a></td>
			<td class="text">{$cats[catloop].name}</td>
	  </tr>
	  {/section}
	</table>
    {else}
<div align="center">No download categories</div>
{/if}
<div align="left"><input type="button" class="button" value="Add Download Category" onclick="window.location='{$pagename}&amp;action=add'" /></div>
  {elseif $action == "view"}
  {if $numdown > 0}
  <h2>Downloads for {$catinfo.name}</h2>
<div align="left"><input type="button" class="button" value="Add Download" onclick="window.location='{$pagename}&amp;action=adddown&amp;id={$catinfo.id}'" /></div>
<table width="100%" border="0" cellspacing="1" cellpadding="4" align="center" class="table">
	  <tr> 
	  <th colspan="4" class="bighead">Downloads for {$catinfo.name}</th>
	</tr>
	  <tr>
		<th width="19%" class="smallhead">Action</th>
        <th class="smallhead">Published</th>
		<th width="26%" class="smallhead">Name</th>
		<th width="55%" class="smallhead">Descripton</th>
	  </tr> 
	 {section name=downloadloop loop=$numdown}
		 <tr>
			<td class="text"><a href="{$downpath}{$downloads[downloadloop].file}"><img src="{$tempdir}admin/images/download.gif" border="0" alt="Download {$downloads[downloadloop].name}" title="Download {$downloads[downloadloop].name}" /></a> - <a href="{$pagename}&amp;action=editdown&amp;id={$catinfo.id}&amp;did={$downloads[downloadloop].id}"><img src="{$tempdir}admin/images/edit.gif" border="0" alt="Edit {$downloads[downloadloop].name}" title="Edit {$downloads[downloadloop].name}" /></a> - <a href="javascript:deletedown({$downloads[downloadloop].id},{$catinfo.id})"><img src="{$tempdir}admin/images/delete.gif" border="0" alt="Delete {$downloads[downloadloop].name}" title="Delete {$downloads[downloadloop].name}" /></a></td>
              <td class="text">{if $downloads[downloadloop].allowed == 0}<a href="javascript:confirmPublish({$downloads[downloadloop].id},{$catinfo.id})"><img src="{$tempdir}admin/images/publish.png" border="0" alt="Publish {$downloads[downloadloop].name}" title="Publish {$downloads[downloadloop].name}" /></a>{else}<a href="javascript:confirmunPublish({$downloads[downloadloop].id},{$catinfo.id})"><img src="{$tempdir}admin/images/unpublish.png" border="0" alt="Unpublish {$downloads[downloadloop].name}" title="Unpublish {$downloads[downloadloop].name}" /></a>{/if}</td>
			<td class="text">{$downloads[downloadloop].name}</td>
			<td class="text">{$downloads[downloadloop].descs}</td>
	  </tr>
	  {/section}
	</table>
    {else}
<div align="center">No downloads in {$catinfo.name}</div>
{/if}
<div align="left"><input type="button" class="button" value="Add Download" onclick="window.location='{$pagename}&amp;action=adddown&amp;id={$catinfo.id}'" />&nbsp;
<input type="button" class="button" value="Back" onclick="window.location='{$pagename}'" /></div>
  {elseif $action=="adddown" || $action=="editdown"}
  <form action="{$editFormAction}" method="post" enctype="multipart/form-data"  name="form1">
    <p align="center">Name of download:<br />
      <input name="name" type="text" id="name" size="60" maxlength="50" value="{$download.name}" class="inputbox" />
      <br />
      Description:      <br />
      <textarea name="desc" cols="50" rows="5" id="desc" class="inputbox">{$download.descs}</textarea>      
      <br />
    Filename{if $action=="editdown"}(Leave blank if you don't want to change the file) - Current Filename: {$download.file}{/if}<br />
    <input name="file" type="file" size="100" class="inputbox" />
    <br />
    <input type="submit" name="Submit" value="Submit" class="button" />
		<input name="Cancel" type="button" id="Cancel" value="Cancel" onclick="history.go(-1);" class="button" />
    </p>
</form>
{elseif $action=="add" || $action == "edit"}
<form name="form2" method="post" action="">
<table width = "100%">
<tr><td class="text" align = "center" colspan="2">
    Category Name: <input name="catname" size="50" value="{$cat.name}"  class="inputbox"/>
    </td>
</tr>
      <tr><th colspan="2" class="bighead">Uploads Authorization</th></tr>
      <tr><th colspan="2" class="smallhead"><div align="left"><input type="button" class="button" value="Allow All" onclick="allowallup(this.form);" id="allowup" /></div></th></tr>
      {section name=groups loop=$numgroups}
      <tr>
      <td align="right" class="text" width="15%">{$group[groups].teamname}</td>
      <td class="text"><div align="left"><input type="checkbox" name="u{$group[groups].id}" id="u{$group[groups].id}" value="1" {if $upauths[groups] == 1}checked{/if} />Allow Uploads</div></td>
      </tr>
      {/section}
      <tr><th colspan="2" class="bighead">Downloads Authorization</th></tr>
      <tr><th colspan="2" class="smallhead"><div align="left"><input type="button" class="button" value="Allow All" onclick="allowalldown(this.form);" id="allowdown" /></div></th></tr>
      <tr>
      <td align="right" class="text">Guests</td>
      <td class="text"><div align="left"><input type="checkbox" id="dguest" name="dguest" value="1" {if $guest == 1}checked{/if} />Allow Downloads</div></td>
      </tr>
      {section name=groups loop=$numgroups}
      <tr>
      <td align="right" class="text">{$group[groups].teamname}</td>
      <td class="text"><div align="left"><input type="checkbox" name="d{$group[groups].id}" id="d{$group[groups].id}" value="1" {if $downauths[groups] == 1}checked{/if} />Allow Downloads</div></td>
      </tr>
      {/section}
  </table>
  <p align="left">
    <input type="submit" name="Submit" value="Submit" class="button" />
        <input name="Cancel" type="button" id="Cancel" value="Cancel" onclick="history.go(-1);" class="button" />
   </p>
</form>
{/if}
<div align="center">
 <a href="http://www.cmscout.za.net/index.php?page=subsite&amp;site=Manual&amp;content=adminpanel-down" target="_blank">Help</a>
</div>
